package cn.seaboot.admin.msg.web;

import cn.seaboot.admin.msg.bean.MessageProperty;
import cn.seaboot.admin.msg.service.MessagePropertyService;
import cn.seaboot.admin.mvc.argument.Params;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.stereotype.Controller;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
* 消息模版参数 [t_sys_msg_props] Controller
* @author Mr.css on 2018-6-20
*/
@Controller
@Tag(name = "消息模版参数 [t_sys_msg_props] 管理")
@RequestMapping("sys/msg/props")
public class MessagePropertyCtrl {

    @Resource
    private MessagePropertyService msgPropsService;

    /**
     * 消息模版参数 - 增
     *
     * @param pojo pojo
     * @return affected rows
     */
    @ResponseBody
    @Operation(description = "消息模版参数 [t_sys_msg_props] 增")
    @RequestMapping(value = "info", method = RequestMethod.POST)
    public int saveInfo(@Validated MessageProperty pojo) {
        return msgPropsService.insert(pojo);
    }

    /**
     * 消息模版参数 - 删
     *
     * @param id id
     * @return affected rows
     */
    @ResponseBody
    @Operation(description = "消息模版参数 [t_sys_msg_props] 删")
    @RequestMapping(value = "info", method = RequestMethod.DELETE)
    public int deleteInfo(@Params String id) {
        return msgPropsService.deleteById(id);
    }

    /**
     * 消息模版参数 - 查
     *
     * @param id id
     * @return pojo
     */
    @ResponseBody
    @Operation(description = "消息模版参数 [t_sys_msg_props] 查")
    @RequestMapping(value = "info", method = RequestMethod.GET)
    public MessageProperty queryById(@Params String id) {
        return msgPropsService.queryById(id);
    }

    /**
     * 消息模版参数 - 改
     *
     * @param pojo pojo
     * @return affected rows
     */
    @ResponseBody
    @Operation(description = "消息模版参数 [t_sys_msg_props] 改")
    @RequestMapping(value = "info", method = RequestMethod.PUT)
    public int updateInfo(@Validated MessageProperty pojo, @Params String id) {
        return msgPropsService.updateById(pojo);
    }

    /**
     * 消息模版参数 - 查列表
     *
     * @param params 参数
     * @return PageInfo
     */
    @ResponseBody
    @Operation(description = "消息模版参数 [t_sys_msg_props] 列表查询")
    @RequestMapping(value = "list", method = RequestMethod.GET)
    public List<MessageProperty> queryList(@RequestParam Map<String, Object> params) {
        return msgPropsService.queryList(params);
    }
}
